﻿using System.Net;
using System.Net.Http;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Optum.SN.Infra.Core.Cryptography.Test.IntegrationTests
{
    /// <summary>
    /// Tests Web API that exposes symmetric cryptography for value lists.
    /// </summary>
    [TestClass]
    public class SymmetricCryptoListWebTest : SymmetricCryptoWebTestBase
    {
        /// <summary>
        /// Tests value list encryption.
        /// </summary>
        [TestMethod]
        public void TestEncryptList()
        {
            var inputList = new MockData();
            TestCryptoFromBody(inputList.GetPlainTextList(), "encryptlist",
                content => AssertEncrypt(inputList, content.ReadAsAsync<CryptoUpdaterList>().Result));
        }
        /// <summary>
        /// Tests value list decryption.
        /// </summary>
        [TestMethod]
        public void TestDecryptList()
        {
            var inputList = new MockData();
            TestCryptoFromBody(inputList.GetCipherTextList(), "decryptlist",
                content => AssertCrypto(inputList, content.ReadAsAsync<CryptoUpdaterList>().Result));
        }
        /// <summary>
        /// Tests value list encryption using the older <see cref="WebClient"/> API.
        /// </summary>
        [TestMethod]
        public void TestEncryptListNet35()
        {
            var inputList = new MockData();
            TestCryptoNet35(inputList.GetPlainTextList(), "encryptlist", output => AssertEncrypt(inputList, output));
        }
        /// <summary>
        /// Tests value list decryption using the older <see cref="WebClient"/> API.
        /// </summary>
        [TestMethod]
        public void TestDecryptListNet35()
        {
            var inputList = new MockData();
            TestCryptoNet35(inputList.GetCipherTextList(), "decryptlist", output => AssertCrypto(inputList, output));
        }
    }
}